package com.homework9;

import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;

public class demo01 {
    public static void main(String[] args) throws IOException {
        FileOutputStream fileOutputStream=new FileOutputStream(new File("D:\\东方标准\\JAVASE阶段\\JAVASE-CODE\\Day18\\info1.txt"),true);
        System.out.println("请以：学号-学生名字格式输入 ");
        while (true){
            String s = new Scanner(System.in).nextLine();
            if(s.equals("end")){
                System.out.println("输入完毕，数据保存成功");
                fileOutputStream.flush();
                break;
            }else{
                String[] splitArr = s.split("-");
                if (splitArr.length!=2){
                    System.out.println("输入格式有误");
                }else{
                    fileOutputStream.write(s.getBytes());
                    fileOutputStream.write("\r\n".getBytes());
                }
            }

        }
    }
}
